import os
from graphviz import Digraph

#mpl.rcParams['font.sans-serif'] = ['Arial Unicode MS']

os.environ["PATH"] += os.pathsep + 'D:/User/sdma/software/Anaconda/bin'
def draw_graph(wdls, heads, relation):
    g = Digraph('测试图片')

    g.node(name='Root')
    for word in wdls:
        g.node(name=word, fontname="Microsoft YaHei")

    for i in range(len(wdls)):
        if relation[i] not in ['HED']:
            g.edge(wdls[i], heads[i], label=relation[i], fontname="Microsoft YaHei")
        else:
            if heads[i] == 'Root':
                g.edge(wdls[i], 'Root', label=relation[i], fontname="Microsoft YaHei")
            else:
                g.edge(heads[i], 'Root', label=relation[i], fontname="Microsoft YaHei")

    g.view()

draw_graph()